//package org.example.demo;
//
//
//import com.alibaba.dubbo.config.annotation.Reference;
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.alibaba.fastjson.serializer.SerializerFeature;
//import com.doone.service.treasureWheel.TwGetAwardService;
//import com.doone.util.AES;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import javax.servlet.http.HttpServletRequest;
//import java.io.BufferedReader;
//import java.io.InputStreamReader;
//import java.util.HashMap;
//import java.util.Map;
//
//
//@Controller
//@RequestMapping("twGetAward")
//public class TwGetAwardCtl {
//
//    @Reference
//   private TwGetAwardService twGetAwardService;
//
//    private Logger logger = LoggerFactory.getLogger(this.getClass());
//
//
//    /**
//     * 用户抽奖总金额查询
//     *
//     * @param
//     * @param
//     * @return
//     */
//    @RequestMapping(value = "findListAwardByphone", method = RequestMethod.POST)
//    @ResponseBody
//    public Object findListAwardByphone(HttpServletRequest request) {
//        Map<String,Object> ret=new HashMap<String, Object>();
//        //获取入参
//        JSONObject jsonParam = this.getJSONParam(request);
//        //参数验证
//        if(jsonParam ==null){
//          ret.put("detail_msg","用户抽奖总金额查询");
//          ret.put("return_code","1");
//          ret.put("return_msg","传入参数不能为空");
//          LoggerFactory.getLogger(this.getClass()).warn(JSON.toJSONString(ret));
//          return JSON.toJSONString(ret);
//        }
//        if(jsonParam.getJSONObject("in").getString("phone")==null || "".equals(jsonParam.getJSONObject("in").getString("phone"))){
//            ret.put("detail_msg","用户抽奖总金额查询");
//            ret.put("return_code","1");
//            ret.put("return_msg","用户手机号不能为空");
//            LoggerFactory.getLogger(this.getClass()).warn(JSON.toJSONString(ret));
//            return JSON.toJSONString(ret);
//        }
//        if(jsonParam.getJSONObject("sec").getString("mac")==null || "".equals(jsonParam.getJSONObject("sec").getString("mac"))){
//            ret.put("detail_msg","用户抽奖总金额查询");
//            ret.put("return_code","1");
//            ret.put("return_msg","非法校验");
//            LoggerFactory.getLogger(this.getClass()).warn(JSON.toJSONString(ret));
//            return JSON.toJSONString(ret);
//        }
//        String macs= AES.Encrypt(jsonParam.getJSONObject("in").getString("phone"));
//        if(!macs.equals(jsonParam.getJSONObject("sec").getString("mac"))){
//            ret.put("detail_msg","用户抽奖总金额查询");
//            ret.put("return_code","1");
//            ret.put("return_msg","字段校验不通过");
//            LoggerFactory.getLogger(this.getClass()).warn(JSON.toJSONString(ret));
//            return JSON.toJSONString(ret);
//        }
//        ret =jsonParam.getJSONObject("in");
//        //查询登录日志
//        Map maps =this.twGetAwardService.findListAwardByphone(ret);
//        Double sums =Double.valueOf(String.valueOf(maps.get("sumAward")))*100;
//
//        logger.warn("微信接口调用参数:"+maps);
//
//        maps.put("sumAward",sums);
//        //查询总条数
//        maps.put("detail_msg","用户抽奖总金额查询");
//        maps.put("return_code","0");
//        maps.put("return_msg","查询成功");
//        maps.put("user_type","ST");
//        return AES.Encrypt(JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue));
//        }
//
//
//
//    public JSONObject getJSONParam(HttpServletRequest request){
//        JSONObject jsonParam = null;
//        try {
//            // 获取输入流
//            BufferedReader streamReader = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
//
//            // 写入数据到Stringbuilder
//            StringBuilder sb = new StringBuilder();
//            String line = null;
//            while ((line = streamReader.readLine()) != null) {
//                sb.append(line);
//            }
//            jsonParam = JSONObject.parseObject(sb.toString());
//            // 直接将json信息打印出来
//            System.out.println(jsonParam.toJSONString());
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return jsonParam;
//    }
//
//}
